﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace IO
{
    class BinaryUtil
    {
        public static void Read(string path)
        {
            if (File.Exists(path) == false)
            {
                return;
            }

            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                using (BinaryReader r = new BinaryReader(fs))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        Console.WriteLine(r.ReadInt32());
                    }
                }
            }
        }


        public static void Write(string path)
        {
            if (File.Exists(path))
            {
                return;
            }

            using (FileStream fs = new FileStream(path, FileMode.CreateNew))
            {
                using (BinaryWriter bw = new BinaryWriter(fs))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        bw.Write(i);
                    }
                }
            }
        }
    }
}
